package com.ruoyi.web.controller.wifi;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.WfUser;
import com.ruoyi.system.service.IWfUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * wifi微信用户信息Controller
 * 
 * @author ruoyi
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/system/wxUser")
public class WfUserController extends BaseController
{
    @Autowired
    private IWfUserService wfUserService;

    /**
     * 查询wifi微信用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:wxUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfUser wfUser)
    {
        startPage();
        List<WfUser> list = wfUserService.selectWfUserList(wfUser);
        return getDataTable(list);
    }

    /**
     * 导出wifi微信用户信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:wxUser:export')")
    @Log(title = "wifi微信用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfUser wfUser)
    {
        List<WfUser> list = wfUserService.selectWfUserList(wfUser);
        ExcelUtil<WfUser> util = new ExcelUtil<WfUser>(WfUser.class);
        util.exportExcel(response, list, "wifi微信用户信息数据");
    }

    /**
     * 获取wifi微信用户信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wxUser:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(wfUserService.selectWfUserByUserId(userId));
    }

    /**
     * 新增wifi微信用户信息
     */
    @PreAuthorize("@ss.hasPermi('system:wxUser:add')")
    @Log(title = "wifi微信用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfUser wfUser)
    {
        return toAjax(wfUserService.insertWfUser(wfUser));
    }

    /**
     * 修改wifi微信用户信息
     */
    @PreAuthorize("@ss.hasPermi('system:wxUser:edit')")
    @Log(title = "wifi微信用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfUser wfUser)
    {
        return toAjax(wfUserService.updateWfUser(wfUser));
    }

    /**
     * 删除wifi微信用户信息
     */
    @PreAuthorize("@ss.hasPermi('system:wxUser:remove')")
    @Log(title = "wifi微信用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(wfUserService.deleteWfUserByUserIds(userIds));
    }
}
